package it.ilgrv.demiurgo.persistence.tables.inscription;

import it.ilgrv.demiurgo.persistence.tables.object.Object;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * The persistent class for the meeting database table.
 * 
 */
@Entity
public class Meeting extends it.ilgrv.demiurgo.persistence.GenericTable implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

    @Temporal( TemporalType.TIMESTAMP)
	private Date endDate;

	private String name;

    @Temporal( TemporalType.TIMESTAMP)
	private Date startDate;

	private int version;

	//bi-directional many-to-one association to Availableassociation
	@OneToMany(mappedBy="meeting")
	private Set<Availableassociation> availableassociations;

	//bi-directional many-to-one association to Object
	@OneToMany(mappedBy="meeting")
	private Set<Object> objects;

	// bi-directional many-to-one association to Partecipant
	@OneToMany(mappedBy="meeting")
	private Set<Partecipant> partecipants;

	//bi-directional many-to-one association to RoleLimit
	@OneToMany(mappedBy="meeting")
	private Set<RoleLimit> roleLimits;

	@Lob
	private String						description;

    public Meeting() {
    }

	public Meeting(String name, Date startDate, Date endDate, String description) {
		this.name = name;
		this.endDate = endDate;
		this.setDescription(description);
		this.startDate = startDate;
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public int getVersion() {
		return this.version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Set<Availableassociation> getAvailableassociations() {
		return this.availableassociations;
	}

	public void setAvailableassociations(Set<Availableassociation> availableassociations) {
		this.availableassociations = availableassociations;
	}

	public Set<Object> getObjects() {
		return this.objects;
	}

	public void setObjects(Set<Object> objects) {
		this.objects = objects;
	}
	
	public Set<Partecipant> getPartecipants() {
		return this.partecipants;
	}

	public void setPartecipants(Set<Partecipant> partecipants) {
		this.partecipants = partecipants;
	}
	
	public Set<RoleLimit> getRoleLimits() {
		return this.roleLimits;
	}

	public void setRoleLimits(Set<RoleLimit> roleLimits) {
		this.roleLimits = roleLimits;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public void addPartecipant(Partecipant p) {
		if (this.partecipants == null) {
			this.partecipants = new HashSet<Partecipant>();
		}

		this.partecipants.add(p);

	}

}